$(function(){
	var
		ev = ev || window.event,
		aLi = $('.box-ul li');
		iSearchIndex  = -1,	
	 	intVal=$(".int1").val();
	$(".int1").focus(function(){
	
		if(intVal){
			$(".int1").removeAttr("placeholder");
		}		
	}).blur(function(){
		if(intVal){
			intVal;
		}
		else if(intVal=""){
			$(".int1").attr("placeholder")
		}

	}).keyup(function (ev) {
			var
				ev = ev || window.event,
				aLi = $('.box-ul li');
			if(ev.keyCode === 38 || ev.keyCode === 40) {
				if(ev.keyCode === 38 && iSearchIndex > 0) {
					
					iSearchIndex--;
				} else if(ev.keyCode === 40 && iSearchIndex < aLi.length - 1) {
					iSearchIndex++;
				}
				// $(".int1").val($(".box-ul li").eq(iSearchIndex).children('a').text())
				$(".int1").val(aLi.removeClass("active").eq(iSearchIndex).addClass('active').children('a').children("b").text())
				// oSeachContent.val(aLi.removeClass('active').eq(iSearchIndex).addClass('active').data('key'));
			}

		}).bind('input propertychange',function(){
		var intVal=$(".int1").val();
			$.ajax({
				url:"https://suggest.taobao.com/sug?code=utf-8&q="+intVal+"&_ksTS=1468638867436_17920&callback=jsonp17921&area=b2c&code=utf-8&k=1&bucketid=9&src=tmall_pc&isg=AsrKs5xUqYzWPCUhLsneFVteG7A0QP7LgGxhLVQAgp24B2fBIUq4JQkxYcYj&isg2=AmRkyvMP4EeDnYxIjeF3FgSKtGxVCYh3",
				dataType:"jsonp",
				data:"intVal",
				success:function(data){

					var html="";
					for(var i=0;i<data.result.length;i++){
						html += '<li><a href="javasript:;"><b>' + data.result[i][0] +'</b><span>'+'约有'+data.result[i][1]+'件'+'</span></a></li>'

					};
					if(html!=""){
						$(".box-ul").html(html+"<li>找<b></b>店铺</li>");
						$(".box-ul li:last b").text(intVal)
					}
					else{
						$(".box-ul").css("display","none")
					}
					
				}
				
			})

		 })
	

	var floorHeight=$('.Floor1').height()
	$(window).scroll(function(){
		var 
			iScroll = $(window).scrollTop(),
			iHeight = $(window).height()
			// console.log(iScroll)
			// console.log(iHeight)
			// console.log(floorHeight)
			if(iScroll+iHeight-floorHeight>$('.Floor1').offset().top){
					$('.Floor10').css('display','block');
				}else{
					$('.Floor10').css('display','none');
				}
	})


	$('.Floor10 ul li').slice(1,10).click(function(){
		$('html,body').stop().animate({
			scrollTop:$('.Floor'+($(this).index())).offset().top
		},'normal');
	});

	$('.Floor10 ul li').last().click(function(){
		$('html,body').stop().animate({
			scrollTop:0
		},'normal');
	});

















});